home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3997 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  971 b 

  1. Path: news.cencom.net!ns!tanp
  2. From: tanp@ns (Bill Wendling)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How to give functions as parameters?
  5. Date: 1 Feb 1996 08:32:17 GMT
  6. Organization: Cen-Com Internet
  7. Message-ID: <4eptqh$jbs@news.cencom.net>
  8. References: <Pine.SUN.3.91N2x.960130222756.11581A-100000@yellow59.nada.kth.se>
  9. NNTP-Posting-Host: ns.cencom.net
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Per Steneskog inexplicably wrote:
  13.  
  14. } I have a little problem, I dont know how to send a fuction,
  15. } as a parameter to another function.. 
  16.  
  17.  
  18.  
  19. } #include <stdio.h>
  20.  
  21. } void
  22. } do_it(void (*it)())
  23. } {
  24. }   ((*(it))());
  25. } }
  26.  
  27. }    
  28. } void
  29. } do_me(
  30. }       void)
  31. } {
  32. }   printf("Testing!");
  33. } }
  34.  
  35.  
  36. } int
  37. } main(
  38. }      void)
  39. } {
  40. }   do_it(do_me()); /* ERROR-COMPILE LINE */
  41.  
  42. Try this:
  43.     do_it(do_me);
  44.  
  45. } }
  46.  
  47.  
  48. Bill Wendling         | "Pinky, are you thinking what I'm thinking?"
  49. tanp@ns.cencom.net  | "I think so, Brain, but burlap chafes me so."
  50. "Boom Shanka"       | Finger me for my Geek Code...NOW!
  51.